import Vue from "vue";
import Vuex from "vuex";

//vuex的数据持久化
import VuexPersist from "vuex-persist";

// 选择一个存储方式
const persist = new VuexPersist({
  storage: window.sessionStorage,
});
Vue.use(Vuex);

export default new Vuex.Store({
  plugins: [persist.plugin],
  strict: true,
  state: {
    userInfo: {
      username: "",
      isLogin: false,
    },
  },
  mutations: {
    SET_USER(state, data) {
      state.userInfo = data;
    },
  },
});
